home *** CD-ROM | disk | FTP | other *** search
-
-
-
- Tcl_Interp Tcl Command Language Library Tcl_Interp
-
-
-
- _________________________________________________________________
-
- NNAAMMEE
- Tcl_Interp - client-visible fields of interpreter structures
-
- SSYYNNOOPPSSIISS
- ##iinncclluuddee <<ttccll..hh>>
-
- typedef struct {
- char *_r_e_s_u_l_t;
- int _d_y_n_a_m_i_c;
- } Tcl_Interp;
-
- _________________________________________________________________
-
-
- DDEESSCCRRIIPPTTIIOONN
- The TTccll__CCrreeaatteeIInntteerrpp procedure returns a pointer to a
- Tcl_Interp structure. This pointer is then passed into
- other Tcl procedures to process commands in the interpreter
- and perform other operations on the interpreter. Inter-
- preter structures contain many many fields that are used by
- Tcl, but only two that may be read and written by clients:
- _r_e_s_u_l_t and _d_y_n_a_m_i_c. These fields are used by Tcl command
- procedures to return strings that form part of the result of
- each command. When Tcl_Eval returns, the string pointed to
- be the _r_e_s_u_l_t field will be used by Tcl_Eval's caller as a
- return value or error message.
-
- The easiest way for command procedures to manipulate the
- _r_e_s_u_l_t and _d_y_n_a_m_i_c fields is to call Tcl_Return; Tcl_Return
- will hide all the details of managing these fields. The
- description below is for those procedures that manipulate
- the fields directly.
-
- Whenever a command procedure returns, it must ensure that
- the _r_e_s_u_l_t field of its interpreter points to the string
- being returned by the command. Normally, these strings are
- assumed to be statically allocated; in this case, the
- _d_y_n_a_m_i_c field must be zero. As an alternative, a command
- procedure may dynamically allocate its return value and
- store a pointer to it in _i_n_t_e_r_p->_r_e_s_u_l_t. In this case, the
- command procedure must also set _i_n_t_e_r_p->_d_y_n_a_m_i_c to non-zero.
- If _i_n_t_e_r_p->_d_y_n_a_m_i_c is non-zero, then Tcl will free the space
- pointed to by _i_n_t_e_r_p->_r_e_s_u_l_t before it invokes the next com-
- mand. If a client procedure overwrites _i_n_t_e_r_p->_r_e_s_u_l_t field
- when _i_n_t_e_r_p->_d_y_n_a_m_i_c is non-zero, then it is responsible for
- freeing the old _i_n_t_e_r_p->_r_e_s_u_l_t. Once again, if clients use
- the TTccll__RReessuulltt procedure to manage these fields, they need
- not worry about these issues.
-
- As part of processing each command, TTccll__EEvvaall initializes
- _i_n_t_e_r_p->_r_e_s_u_l_t and _i_n_t_e_r_p->_d_y_n_a_m_i_c just before calling the
- command procedure for the command. The _d_y_n_a_m_i_c field will
-
-
-
- Sprite v.1.0 Printed: February 3, 1990 1
-
-
-
-
-
-
- Tcl_Interp Tcl Command Language Library Tcl_Interp
-
-
-
- be initialized to zero, and _i_n_t_e_r_p->_r_e_s_u_l_t will point to an
- empty string. Commands that do not return any value can
- simply leave the fields alone. Furthermore, the empty
- string pointed to by _r_e_s_u_l_t is actually part of an array of
- TTCCLL__RREESSUULLTT__SSIIZZEE characters (approximately 200). If a com-
- mand wishes to return a short string, it can simply copy it
- to the area pointed to by _i_n_t_e_r_p->_r_e_s_u_l_t. Or, it can use
- the sprintf procedure to generate a short result string at
- the location pointed to by _i_n_t_e_r_p->_r_e_s_u_l_t.
-
- If a command procedure calls a lower-level procedure that
- sets _i_n_t_e_r_p->_r_e_s_u_l_t and _i_n_t_e_r_p->_d_y_n_a_m_i_c (such as a recursive
- instance of TTccll__EEvvaall), then the command procedure must reset
- _i_n_t_e_r_p->_r_e_s_u_l_t if it wishes to return a value different than
- that returned by the lower-level procedure. As part of
- resetting _i_n_t_e_r_p->_r_e_s_u_l_t, it must free the space if _i_n_t_e_r_p-
- >_d_y_n_a_m_i_c is set. Once again, the easiest way to make sure
- this gets done right is to call TTccll__RReessuulltt.
-
-
- KKEEYYWWOORRDDSS
- dynamic, interpreter, result
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Sprite v.1.0 Printed: February 3, 1990 2
-
-
-
-